import { Common } from '../../utils/common.js';
var common = new Common();

let Wxparse = require("../../wxParse/wxParse.js");

Page({

  /**
   * 页面的初始数据
   */
  data: {
    status:'display',
    style:'height: 100rpx;overflow: hidden;',
    text:'显示全部',
    scroll:'',
    toView: '',
  },

  //锚点跳转
  float:function(e){
    //打开全部
    this.setData({
      status: 'hidden',
      style: 'height: 1200rpx;',
      scroll: 'height: 100%;',
      text: '收起全部',
    });
    //再跳转
    this.setData({
      status: 'hidden',
      style: 'height: 1200rpx;',
      scroll: 'height: 100%;',
      toView:e.currentTarget.dataset.id,
      text: '收起全部',
    })
  },
  display:function(){
    this.setData({
      status:'hidden',
      style: 'height: 1200rpx;',
      scroll: 'height: 100%;',
      text: '收起全部',
    })
  },
  hidden: function () {
    this.setData({
      status: 'display',
      style: 'height: 100rpx;overflow: hidden;',
      scroll: '',
      text: '显示全部',
    })
  },

  //前往上传
  upload:function(){
    wx.navigateTo({
      url: '../upload_visa/upload?navigatenumber=2',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    var datas = {
      data: { type: '1' },
      type:'post',
      url:'strategy',
    }

    common.DataToData(datas,data=>{
      var strategy_content = data.strategy.category_content;
      this.setData({
        strategy_info:data.strategy,
        advert: data.advert,
      })

      var strategy_arr = [];

      for (let i = 0; i < strategy_content.length;i++){
        strategy_arr.push(strategy_content[i].content);
      }
  
      for (let i = 0; i < strategy_arr.length; i++) {
        Wxparse.wxParse('reply' + i, 'html', strategy_arr[i], this);
        if (i === strategy_arr.length - 1) {
          Wxparse.wxParseTemArray("replyTemArray", 'reply', strategy_arr.length, this)
        }
      }

    })
  },

  //选择跳转咨询还是外部链接
  detail: function (e) {
    if (e.currentTarget.dataset.url == '') {
      wx.switchTab({
        url: '../service/service',
      })
    } else {
      wx.navigateTo({
        url: '../outside/outside?url=' + e.currentTarget.dataset.url,
      })
    }
  },
})